package club.kingyin.easycache.core;

import club.kingyin.easycache.method.core.PointEasyCacheEnhancer;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Aspect
public class PointEasyCache {

    @Resource
    private PointEasyCacheEnhancer pointEasyCacheEnhancer;

    @Pointcut("@annotation(club.kingyin.easycache.component.annotation.EasyCache) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Expire) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Ignore) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.CacheHandler) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.InvokeException) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.InvokeHandler) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.MethodName) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Module) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Param) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Remove) ||" +
            " @annotation(club.kingyin.easycache.component.annotation.Removes)"
    )
    public void pt(){}

    @Around("pt()")
    public Object cache(ProceedingJoinPoint joinPoint) {
        return pointEasyCacheEnhancer.proceed(joinPoint);
    }
}
